package com.gitee.lirenqing.flinksimpledatamysqlsource;


import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.sink.RichSinkFunction;

public class FlinkSimpleDataMysqlSourceApplication {

    public static void main(String[] args) {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<String> dataStreamSource = env.addSource(new MysqlRichSource());
        dataStreamSource.addSink(new RichSinkFunction<String>() {
            @Override
            public void open(Configuration parameters) throws Exception {
                super.open(parameters);
            }

            @Override
            public void close() throws Exception {
                super.close();
            }

            @Override
            public void invoke(String value, Context context) throws Exception {
                System.out.println("mysql sink :" + value);
            }
        });

        try {
            env.execute("data mysql sink");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
